<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>dconv</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="dcblock2.html" title="dcblock2" />
    <link rel="next" href="delay.html" title="delay" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">dconv</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="dcblock2.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="delay.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="dconv"></a>
      <div class="titlepage"></div>
      <a id="IndexDconv" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">dconv</span>
        </h2>
        <p>dconv — 
      A direct convolution opcode.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98034784"></a>
        <h2>Description</h2>
        <p>
      A direct convolution opcode.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98098432"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>dconv</strong></span> asig, isize, ifn</pre>
      </div>
      <div class="refsect1">
        <a id="idp98100608"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>isize</em></span> -- the size of the convolution buffer to use. If the buffer size is smaller than the size of <span class="emphasis"><em>ifn</em></span>, then only the first <span class="emphasis"><em>isize</em></span> values will be used from the table.
    </p>
        <p>
      <span class="emphasis"><em>ifn</em></span> -- table number of a stored function containing the impulse response for convolution.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98104032"></a>
        <h2>Performance</h2>
        <p>
      Rather than the analysis/resynthesis method of the <span class="emphasis"><em>convolve</em></span> opcode, <span class="emphasis"><em>dconv</em></span> uses direct convolution to create the result.  For small tables it can do this quite efficiently, however larger table require much more time to run. <span class="emphasis"><em>dconv</em></span> does (<span class="emphasis"><em>isize</em></span> * <span class="emphasis"><em>ksmps</em></span>) multiplies on every k-cycle. Therefore, reverb and delay effects are best done with other opcodes (unless the times are short).
    </p>
        <p>
      <span class="emphasis"><em>dconv</em></span> was designed to be used with time varying tables to facilitate new realtime filtering capabilities.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98108672"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the dconv opcode. It uses the file <a class="ulink" href="examples/dconv.csd" target="_top"><em class="citetitle">dconv.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp98110528"></a>
          <p class="title">
            <strong>Example 174. Example of the dconv opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o dconv.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 4410
<span class="ohdr">ksmps</span> <span class="op">=</span> 10
<span class="ohdr">nchnls</span> <span class="op">=</span> 1
 
<span class="omacro">#define</span> RANDI(A) #kout  <span class="opc">randi</span>   1, kfq, $A<span class="op">*</span>.001<span class="op">+</span>iseed, 1
        <span class="opc">tablew</span>  kout, $A, itable#
 
<span class="oblock">instr</span> 1
itable  <span class="opc">init</span>    1
iseed   <span class="opc">init</span>    .6
isize   <span class="opc">init</span>    <span class="opc">ftlen</span>(itable)
kfq     <span class="opc">line</span>    1, p3, 10
 
$RANDI(0)
$RANDI(1)
$RANDI(2)
$RANDI(3)
$RANDI(4)
$RANDI(5)
$RANDI(6)
$RANDI(7)
$RANDI(8)
$RANDI(9)
$RANDI(10)
$RANDI(11)
$RANDI(12)
$RANDI(13)
$RANDI(14)
$RANDI(15)

asig    <span class="opc">rand</span>    10000, .5, 1
asig    <span class="opc">butlp</span>   asig, 5000
asig    <span class="opc">dconv</span>   asig, isize, itable
 
        <span class="opc">out</span>     asig <span class="op">*</span>.5
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">f</span>1 0 16 10 1
<span class="stamnt">i</span>1 0 10
<span class="stamnt">e</span>


<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98114816"></a>
        <h2>See also</h2>
        <p>
      <a class="link" href="pconvolve.html" title="pconvolve"><em class="citetitle">pconvolve</em></a>,
      <a class="link" href="convolve.html" title="convolve"><em class="citetitle">convolve</em></a>,
      <a class="link" href="ftconv.html" title="ftconv"><em class="citetitle">ftconv</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp98118784"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: William <span class="quote">“<span class="quote">Pete</span>”</span> Moss</td>
          </tr>
          <tr>
            <td>2001</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 4.12</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="dcblock2.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="delay.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">dcblock2 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> delay</td>
        </tr>
      </table>
    </div>
  </body>
</html>
